package cn.chenmixuexi.protocol.serializer;

import cn.chenmixuexi.message.PingMessage;
import cn.chenmixuexi.message.PongMessage;
import cn.chenmixuexi.message.RpcRequestMessage;
import cn.chenmixuexi.message.RpcResponseMessage;
import com.google.gson.*;
import lombok.extern.slf4j.Slf4j;

import java.io.*;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

public abstract class Serializer {
    public abstract <T> T deserialize(Class<T> clazz, byte[] bytes);
    public abstract <T> byte[] serialize(T obj) throws IOException;
    public abstract int getId();

    public static final int Java = 0;
    public static final int Json = 1;
    public static final Map<Integer, Class<?>> serializerClasses = new HashMap<>();

    static {
        serializerClasses.put(Java, JDKSerializer.class);
        serializerClasses.put(Json, JSONSerializer.class);
    }
}
